home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-07-13 | 2.3 KB | 95 lines | [TEXT/ds30] |
- declare procedure setv(str, val, which)
- argument varchar str = $null;
- argument generic val = $null;
- argument integer which = $null;
- {
- boolean opened_master = $false;
- varchar type, value, string;
- objname var;
- integer i;
-
- describe open databases;
- if ($rowcnt == 0) {
- opened_master = $true;
- open database master;
- }
-
- if (str is null) {
- select a.creatorname, a.name, b.datatype, b.value
- from sysobjects a, sysvariables b
- where a.dbid = b.dbid for extract;
- }
- else {
- select a.creatorname, a.name, b.datatype, b.value
- from sysobjects a, sysvariables b
- where a.name like :str and
- a.dbid = b.dbid for extract;
- }
- if ($rowcnt == 0)
- print "No match found for '"+str+"'.";
- else {
- i = 1;
- for each {
- if (->datatype == $integer)
- type = "INTEGER";
- else if (->datatype == $smint)
- type = "SMINT";
- else if (->datatype == $date)
- type = "DATE";
- else if (->datatype == $timestamp)
- type = "TIMESTAMP";
- else if (->datatype == $time)
- type = "TIME";
- else if (->datatype == $date)
- type = "DATE";
- else if (->datatype == $decimal)
- type = "DECIMAL";
- else if (->datatype == $boolean)
- type = "BOOLEAN";
- else
- type = "";
- if (->value is null)
- value = "$NULL";
- else
- execute "value = VARCHAR(" + type + " ->value);";
- if (->datatype == $varchar)
- string = """" + value + """";
- else
- string = value;
- string = "SET VARIABLE " + ->creatorname + "." + ->name + " = " + string;
- if (val is not null) {
- if ($rowcnt == 1 or (which is not null and i == which)) {
- var = ->creatorname + "." + ->name;
- if (varchar val == value)
- string = string + " == ";
- else {
- SET VARIABLE var = val;
- string = string + " -> ";
- }
- if (->datatype == $varchar)
- string = string + """" + varchar val + """";
- else
- string = string + varchar val;
- }
- }
- if ($rowcnt > 1) {
- string = "(" + varchar i + ") " + string;
- i++;
- }
- print string + ';';
- }
- if (val is not null) {
- if (which is not null) {
- if (which <= 0 or which > $rowcnt)
- print "Selected value "+varchar which+", is out of range";
- }
- else if ($rowcnt > 1)
- print "No value set, '"+str+"' is ambiguous.";
- }
- }
-
- if (opened_master)
- close database master;
- }
- end procedure setv;
-